// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   Gizmo.java

package jones.behavior;

import jones.SimpleRobotInterface;
import jones.ValueNotAvailableException;

// Referenced classes of package jones.behavior:
//            Behavior, Arbiter

public class Gizmo
    implements Behavior
{

    private static final String NAME = "Gizmo";
    private double gain = 0;
    private double light = 0;
    private boolean isOriented = false;

    public Gizmo()
    {
        gain = 2D;
        light = 50D;
        isOriented = false;
    }

    public Gizmo(double gain, double light)
    {
        this.gain = 2D;
        this.light = 50D;
        isOriented = false;
        this.gain = gain;
        this.light = light;
    }

    public String getName()
    {
        return "Gizmo";
    }

    public double getGain()
    {
        return gain;
    }

    public void setGain(double gain)
    {
        this.gain = gain;
    }

    public double getLight()
    {
        return light;
    }

    public void setLight(double light)
    {
        this.light = light;
    }

    public void update(double d)
    {
    }

    public void act(Arbiter arbiter)
    {
        SimpleRobotInterface robot = (SimpleRobotInterface)arbiter.getRobotInterface(((Behavior) (this)));
        try
        {
            double measuredLight = (robot.getLeftPhoto() + robot.getRightPhoto()) / 2;
            double error = light - measuredLight;
            double velocity = gain * error;
            robot.setLeftWheelSpeed((int)velocity);
            robot.setRightWheelSpeed((int)velocity);
        }
        catch (ValueNotAvailableException ex) { }
    }

    public String toString()
    {
        return "Gizmo";
    }
}
